package com.ruoyi.foodworks.service.impl;

import java.util.List;

import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.foodworks.mapper.CommentsLikesMapper;
import com.ruoyi.foodworks.mapper.FoodWorksCommentsMapper;
import com.ruoyi.foodworks.domain.CommentsLikes;
import com.ruoyi.foodworks.service.CommentsLikesService;

/**
 * 评论点赞Service业务层处理
 * 
 * @author ruoyi
 * @date 2025-08-12
 */
@Service
public class CommentsLikesServiceImpl implements CommentsLikesService
{
    @Autowired
    private CommentsLikesMapper commentsLikesMapper;

    @Autowired
    private FoodWorksCommentsMapper commentsMapper;

    /**
     * 查询评论点赞
     * 
     * @param id 评论点赞主键
     * @return 评论点赞
     */
    @Override
    public CommentsLikes selectCommentsLikesById(Integer id)
    {
        return commentsLikesMapper.selectCommentsLikesById(id);
    }

    /**
     * 查询评论点赞列表
     * 
     * @param commentsLikes 评论点赞
     * @return 评论点赞
     */
    @Override
    public List<CommentsLikes> selectCommentsLikesList(CommentsLikes commentsLikes)
    {
        return commentsLikesMapper.selectCommentsLikesList(commentsLikes);
    }

    /**
     * 新增评论点赞
     * 
     * @param commentsLikes 评论点赞
     * @return 结果
     */
    @Override
    public int insertCommentsLikes(CommentsLikes commentsLikes)
    {
        commentsLikes.setCreateTime(DateUtils.getNowDate());
        return commentsLikesMapper.insertCommentsLikes(commentsLikes);
    }

    /**
     * 修改评论点赞
     * 
     * @param commentsLikes 评论点赞
     * @return 结果
     */
    @Override
    public int updateCommentsLikes(CommentsLikes commentsLikes)
    {
        return commentsLikesMapper.updateCommentsLikes(commentsLikes);
    }

    /**
     * 批量删除评论点赞
     * 
     * @param ids 需要删除的评论点赞主键
     * @return 结果
     */
    @Override
    public int deleteCommentsLikesByIds(Integer[] ids)
    {
        return commentsLikesMapper.deleteCommentsLikesByIds(ids);
    }

    /**
     * 删除评论点赞信息
     * 
     * @param id 评论点赞主键
     * @return 结果
     */
    @Override
    public int deleteCommentsLikesById(Integer id)
    {
        return commentsLikesMapper.deleteCommentsLikesById(id);
    }
    
    /**
     * 根据用户ID和评论ID查询点赞记录
     * 
     * @param userId 用户ID
     * @param commentId 评论ID
     * @return 点赞记录
     */
    @Override
    public CommentsLikes selectCommentsLikesByUserAndComment(Integer userId, Integer commentId)
    {
        return commentsLikesMapper.selectCommentsLikesByUserAndComment(userId, commentId);
    }
    
    /**
     * 获取评论的点赞数
     * 
     * @param commentId 评论ID
     * @return 点赞数
     */
    @Override
    public int getCommentLikeCount(Integer commentId)
    {
        return commentsLikesMapper.getCommentLikeCount(commentId);
    }
}
